import java.util.Arrays;
public class MyStack{
    private int[] elem;
    private int usedSize;

    private static final int DEFAULT_SIZE = 10;

    public MyStack(){
        this.elem = new int[DEFAULT_SIZE];
    }

    //push
    public void push(int i){
        if(isFull()){
            elem = Arrays.copyOf(elem,elem.length*2);
        }
        elem[usedSize] = i;
        usedSize++;
    }
    public boolean isFull(){
        return elem.length == usedSize;
    }

    //pop
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        int oldVal = elem[usedSize - 1];
        usedSize--;
        return oldVal;
    }

    //peek
    public int peek(){
        if(isEmpty()){
            return -1;
        }
        return elem[usedSize -1];
    }

    //isEmpty
    public boolean isEmpty(){
       return usedSize == 0;
    }

}
